package cn.tedu.spring.di;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Controller;
import org.springframework.stereotype.Repository;
import org.springframework.stereotype.Service;


/**
 * Component
 * Repository
 * Service
 * Controller
 * @Value依赖注解，注解基本的类型数据
 * 属性值，必须以是字符串的方式注入 否则会报错
 * 添加位置
 * 添加到属性上
 * 2添加到set方法上
 * 只能注入基本类型不可注入其他类型
 */
@Component
public class UserDao {
    @Value("JDBC;MySQL;//localhost:tear")
    private String url;
    @Value("root")
    private String name;
//    @Value("root")
//    private String password;
    private String password;
    @Value("root")
    public void setPassword(String password){
        this.password=password;
    }

    @Override
    public String toString() {
        return "UserDao{" +
                "url='" + url + '\'' +
                ", name='" + name + '\'' +
                ", password='" + password + '\'' +
                '}';
    }
}
